<template>
  <div class="book-container">
    <h1>图书管理系统</h1>
    <table class="book-table">
      <thead>
        <tr>
          <th>序号 (ID)</th>
          <th>书名 (Name)</th>
          <th>作者 (Author)</th>
          <th>简介 (Introduction)</th>
          <th>图书编号 (Number)</th>
        </tr>
      </thead>
      <tbody>
        <!-- 使用 v-for 循环渲染图书数据 -->
        <tr v-for="book in books" :key="book.id">
          <td>{{ book.id }}</td>
          <td>{{ book.name }}</td>
          <td>{{ book.author }}</td>
          <td>{{ book.introduction }}</td>
          <td>{{ book.number }}</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
export default {
  name: 'ProgrammingBooks',
  data() {
    return {
      // 这是根据您截图中的数据生成的静态数组
      // 将来您可以从后端API获取这些数据
      books: [
        { id: 1, name: '《java》', author: 'java', introduction: 'java是java', number: '1001' },
        { id: 2, name: '《python》', author: 'python', introduction: 'python是python', number: '1002' },
        { id: 3, name: '《c++》', author: 'c++', introduction: 'c++是c++', number: '1003' },
        { id: 4, name: '《c#》', author: 'c#', introduction: 'c#是c#', number: '1004' },
        { id: 5, name: '《go》', author: 'go', introduction: 'go是go', number: '1005' },
        { id: 6, name: '《php》', author: 'php', introduction: 'php是php', number: '1006' },
        { id: 7, name: '《ruby》', author: 'ruby', introduction: 'ruby是ruby', number: '1007' }
      ]
    }
  }
}
</script>

<style scoped>
/* 这里是一些美化表格的样式 */
.book-container {
  width: 90%;
  max-width: 1200px;
  margin: 40px auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

h1 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
}

.book-table {
  width: 100%;
  border-collapse: collapse; /* 合并边框 */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
   /* 保证圆角效果 */
}

.book-table th, .book-table td {
  border: 1px solid #e0e0e0;
  padding: 15px;
  text-align: left;
}

.book-table thead tr {
  background-color: #007bff;
  color: #ffffff;
  font-size: 16px;
}

.book-table tbody tr {
  background-color: #fff;
  transition: background-color 0.2s ease-in-out;
}

.book-table tbody tr:nth-of-type(even) {
  background-color: #f8f9fa;
}

.book-table tbody tr:hover {
  background-color: #e9ecef; /* 鼠标悬停时的背景色 */
}

.book-table td:first-child, .book-table th:first-child {
    text-align: center;
}

.book-table td:last-child, .book-table th:last-child {
    text-align: center;
}
</style>